package com.zzyl.nursing.controller.member;

import com.aliyun.iot20180120.models.QueryDevicePropertyStatusRequest;
import com.aliyun.iot20180120.models.QueryThingModelPublishedRequest;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.domain.FamilyMemberElder;
import com.zzyl.nursing.dto.FamilyAddDto;
import com.zzyl.nursing.dto.QueryDeviceDataListByDayDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IDeviceService;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.FamilyElderVo;
import com.zzyl.nursing.vo.FamilyMemberDayVo;
import com.zzyl.nursing.vo.FamilyMemberElderVo;
import com.zzyl.nursing.vo.LoginVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 *
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController {
    @Autowired
    private IFamilyMemberService familyMemberService;

    @Autowired
    private IDeviceService deviceService;

    /**
     * 小程序登录
     *
     * @param dto
     * @return
     */
    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto) {
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }


    /**
     * 绑定家属
     *
     * @param dto
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("绑定家属")
    public AjaxResult familyAdd(@RequestBody FamilyAddDto dto) {
        familyMemberService.familyAdd(dto);
        return success();
    }

    /**
     * 查询探访家人列表
     *
     * @return
     */
    @GetMapping("/my")
    @ApiOperation("查询探访家人列表")
    public AjaxResult familyList() {
        List<FamilyMemberElderVo> list = familyMemberService.familyElderList();
        return success(list);
    }

    /**
     * 查询家人列表
     *
     * @return
     */
    @GetMapping("/list-by-page")
    @ApiOperation("查询家人列表")
    public AjaxResult familyMemberList() {
        List<FamilyElderVo> list = familyMemberService.familyList();
        return success(list);
    }

    /**
     * 查询健康数据
     *
     * @param
     * @return
     */
    @PostMapping("/QueryDevicePropertyStatus")
    public AjaxResult queryDevicePropertyStatus(@RequestBody QueryDevicePropertyStatusRequest request){
        return deviceService.queryDevicePropertyStatus(request);
    }

    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天统计查询指标数据")
    public AjaxResult queryDeviceDataListByDay(QueryDeviceDataListByDayDto dto){
        List<FamilyMemberDayVo>  list = familyMemberService.queryDeviceDataListByDay(dto);
        return success(list);
    }


    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周统计查询指标数据")
    public AjaxResult queryDeviceDataListByWeek(QueryDeviceDataListByDayDto dto){
        List<FamilyMemberDayVo>  list = familyMemberService.queryDeviceDataListByWeek(dto);
        return success(list);
    }


}
